home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Application.h
-
- Contains: TApplication interface
-
- Copyright: © 1991-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __APPLICATION__
- #define __APPLICATION__
-
- #ifndef __LIBRARYMANAGER__
- #include <LibraryManager.h>
- #endif
-
- #ifndef __DESK__
- #include <Desk.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
-
- class TDocument;
- class TDocumentList;
-
- /*
- TApplication:
-
- This is our class which implements a basic Macintosh style program,
- including a MultiFinder-aware event loop.
- */
-
- #define kTApplicationID "appl:insp$TApplication,1.2"
-
- class TApplication : public TDynamic
- {
- public:
- // Our constructor & destructor
- TApplication(QDGlobals* qdPtr, BooleanParm initToolbox = true);
- TApplication();
- virtual ~_CDECL TApplication();
-
- // Call this routine to start event loop running
- virtual void _CDECL EventLoop();
-
- // Utility routines you can use
- inline TDocumentList* DocList() { return fDocList; }
-
- protected:
- // Returns total stack space required in bytes.
- // Returns 0 by default, which tells the initialization code
- // to use the default stack size.
- virtual long StackNeeded();
- // Returns total heap space required in bytes.
- // Returns 0 by default, which tells the initialization code
- // to use whatever heap size is given.
- virtual long HeapNeeded();
-
- static void AlertUser(short errResID, short errCode);
- static void BigBadError(short errResID, short errCode);
-
- // Loop control methods you may need to override
- virtual void SetUp(); // Run before event loop starts
- virtual void CleanUp(); // run at end of loop
- virtual void ExitLoop(); // to end loop, call this routine
- virtual void DoIdle(); // idle time handler (blink caret, background tasks)
- virtual void AdjustMenus(); // menu updater routine
-
- // event handlers you shouldn't need to override in a typical application
- virtual void DoKeyDown(); // also called for autokey events
- virtual void DoActivateEvt(); // handles setup, and calls DoActivate (below)
- virtual void DoUpdateEvt(); // handles setup, and calls DoUpdate (below)
- virtual void DoOSEvent(); // Calls DoSuspend, DoResume and DoIdle as apropos
- virtual void DoMouseDown(); // Calls DoContent, DoGrow, DoZoom, etc
- virtual void DoMouseInSysWindow();
- virtual void DoDrag();
- virtual void DoGoAway(); // handles setup, calls TDocument::DoClose
-
- // called by EventLoop and its handlers:
- virtual void AdjustCursor(); // cursor adjust routine, should setup mouseRgn
- virtual void DoMenuCommand(short menuID, short menuItem);
- // called by OSEvent (just calls DoActivate by default, so no clip conversion
- // is done). If you want to convert clipboard, override these routines
- virtual void DoSuspend(Boolean doClipConvert);
- virtual void DoResume(Boolean doClipConvert);
-
- // If you have an app that needs to know about these, override them
- virtual void DoMouseUp();
- virtual void DoDiskEvt();
-
- // Utility routines you need to provide to do MultiFinder stuff
- virtual unsigned long SleepVal(); // how long to sleep in WaitNextEvent
-
- private:
- virtual void InitApplication(QDGlobals* qdPtr, Boolean initToolbox);
-
- protected:
- // useful variables
- Boolean fHaveWaitNextEvent; // true if we have WaitNextEvent trap
- Boolean fDone; // set to true when we are ready to quit
- EventRecord fTheEvent; // our event record
- WindowPtr fWhichWindow; // currently active window
- Boolean fInBackground; // true if our app is suspended
- Boolean fWantFrontClicks; // true if we want front clicks
- RgnHandle fMouseRgn; // mouse moved region (set it in your DoIdle)
- TDocument* fCurDoc; // currently active document (if any)
- TDocumentList* fDocList; // the list of documents
- QDGlobals* fqd; // pointer to our qd globals
- };
-
- #endif
-